package com.kx.controller;

import com.kx.dao.QueryDao;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class QueryProvinceNameServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理get请求
        String strProid = request.getParameter("proid");
        System.out.println("strProid:" + strProid);

        String name = "默认是无数据";
        //访问dao，查询数据库
        //!"".equals(strProid.trim())表示去掉空格后不为空
        if (strProid != null && !"".equals(strProid.trim())) {
            QueryDao dao = new QueryDao();
            name = dao.queryProvinceNameById(Integer.valueOf(strProid));

        }

        //使用HttpServletResponse输出数据
        response.setContentType("text/html;charset=utf-8");
        PrintWriter pw = response.getWriter();
        pw.println(name);
        pw.flush();
        pw.close();
    }
}
